﻿/*----------------------------------------------------------------
// Copyright (C) 2015 HYBY
//
// 文件名：        TBBeans.cs
// 文件功能描述：   业务表，执行人的豆豆记录表
//
// 
// 创建标识：      吕天瑞 2016-06-07
//
// 修改标识：
// 修改描述： 
// 
// 备注：	
// 				
//----------------------------------------------------------------*/

using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using HYBY.Task.DataEntity;
using HYBY.Task.Repository.IRepository;

namespace HYBY.Task.Repository 
{
    public partial class TBBeansRepository : BaseRepository<TBBeansEntity>, ITBBeansRepository 
    {

        #region 常量    

        private const String CONST_GetTBBeans = "TaskPlatformDB#GetTBBeans";
        private const String CONST_GetTBBeanss = "TaskPlatformDB#GetTBBeanss";
        private const String CONST_GetTBBeansPaged = "TaskPlatformDB#GetTBBeansPaged";
        private const String CONST_GetTBBeansRecordCount = "TaskPlatformDB#GetTBBeansRecordCount";
        private const String CONST_SaveTBBeans = "TaskPlatformDB#SaveTBBeans";
        private const String CONST_DeleteTBBeans = "TaskPlatformDB#DeleteTBBeans";

        #endregion

        #region 构造器

        public TBBeansRepository() {

        }

        #endregion

        #region 公共方法

        /// <summary>
        /// 返回业务表，执行人的豆豆记录表
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        public override TBBeansEntity Get(object Id) 
        {
            return Query<TBBeansEntity>(CONST_GetTBBeans, new { ID = Id }).ToList().FirstOrDefault();
        }

        /// <summary>
        /// 返回所有业务表，执行人的豆豆记录表
        /// </summary>
        /// <returns></returns>
        public List<TBBeansEntity> GetTBBeanss()
        {
            return Query<TBBeansEntity>(CONST_GetTBBeanss).ToList();
        }


        /// <summary>
        /// 分页方式返回业务表，执行人的豆豆记录表
        /// </summary>
        /// <param name="PageIndex">页面索引</param>
        /// <param name="PageSize">页面大小</param>
        /// <param name="RecordCount">总记录数</param>
        /// <returns></returns>
        public List<TBBeansEntity> GetTBBeanss(int pageIndex,int pageSize,out int recordCount)
        {
            recordCount = Query<Int32>(CONST_GetTBBeansRecordCount).FirstOrDefault();
            return Query<TBBeansEntity>(CONST_GetTBBeansPaged, new { PageIndex = pageIndex,PageSize=pageSize }).ToList();
        }

        /// <summary>
        /// 保存领域实体到持久化存储业务表，执行人的豆豆记录表
        /// </summary>
        /// <param name="entity">领域实体</param>    
        /// <returns></returns>
        public override bool Save(TBBeansEntity entity) 
        {
            return Execute(CONST_SaveTBBeans, entity) > 0;
        }

        /// <summary>
        /// 从持久化存储中删除业务表，执行人的豆豆记录表
        /// </summary>
        /// <param name="entity">领域实体</param>    
        /// <returns></returns>
        public override bool Delete(TBBeansEntity entity) 
        {
          return Execute(CONST_DeleteTBBeans, new {  id = entity.id }) > 0;
        }

        #endregion
    }  
}

